package at.main.gui;

import at.main.android.Graphics;
import at.main.util.AllImage;
import at.main.util.ConfigPanel;
import at.main.util.ConstGame;

public class ManagerMonster {
	public static int iV = 0; // Van toc cua cac Monster

	public static int iSizeMonster = 0;

	public static int iCountMonster = 4;

	public static Monster[] arrMonster;

//	public boolean isMonster = false;

	public static boolean isState = true; // chuyển trang thái nếu con pacman
											// ăn được iTems
	public long lTime;
	public ManagerMonster()
	{
		iV = 4;
		iCountMonster = 4;
		arrMonster = new Monster[iCountMonster];		
		iSizeMonster = 24;
		lTime = MyCanvas.Timer();	
		isState = true;
		initManagerMonster();
	}
	public ManagerMonster(int v,int count) {
		isState = true;
		iV = v;
		iCountMonster = count;
		arrMonster = new Monster[iCountMonster];		
		iSizeMonster = 24;
		lTime = MyCanvas.Timer();		
		initManagerMonster();
	}	
	public void ManagerMonster1(int v,int count){
		arrMonster = new Monster[iCountMonster];
		iV =v;
		iCountMonster=count;
		iSizeMonster = 24;
		lTime = MyCanvas.Timer();		
		initManagerMonster();
	}
	public static void initManagerMonster() {
		// System.out.println("<<<<<<<<<<<<< int manager monster");
		for (int i = 0; i < iCountMonster; i++) {			
			Monster m = new Monster(ConstGame.arrXPosMonsters[i],
					ConstGame.arrYPostMonsters[i]+ConfigPanel.heightPanel(), iV, AllImage.img_arrMonster0);
			arrMonster[i] = m;
		}
	}

	// Cap nhat lai vi tri cho cac con monster
	public void update() {
		boolean isFlag = true;
		for (int i = 0; i < iCountMonster; i++) {
			// Con song thi goi ham update
			if (arrMonster[i].isLife){			
				arrMonster[i].update();
				isFlag = false;
			}
		}
		//Cac con monster da chet het rui nen sinh ra tiep 
		if(isFlag){
			ManagerMonster1(iV,iCountMonster);
			isState = true;
		}
	}

	// Ve cac con monster
	public void paint(Graphics g) {
		
		for (int i = 0; i < iCountMonster; i++) {
			// Con song thi moi ve len man hinh		
			if (arrMonster[i].isLife)
				arrMonster[i].paint(g);
		}
	}
}
